USE [Monitoring]
GO

--|--------------------------------------------------------------------------------
--| [GetEntityAttributeByID] - Insert Procedure Script for EntityAttribute
--|--------------------------------------------------------------------------------
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id (N'[dbo].[GetEntityAttributeByID]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1) 
  DROP PROCEDURE [dbo].[GetEntityAttributeByID]
GO

/*CREATE PROCEDURE [dbo].[GetEntityAttributeByID]
(
	@ID int
)
AS
	SET NOCOUNT ON

	SELECT
		[ID],
		[EntityID],
		[EntityAttributeTypeID],
		[Value]
	FROM 
EntityAttribute
	WHERE
		[ID] = @ID
	
GO
*/

--|--------------------------------------------------------------------------------
--| [InsertEntityAttribute] - Insert Procedure Script for EntityAttribute
--|--------------------------------------------------------------------------------
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id (N'[dbo].[InsertEntityAttribute]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1) 
  DROP PROCEDURE [dbo].[InsertEntityAttribute]
GO

/*CREATE PROCEDURE [dbo].[InsertEntityAttribute]
(
	@ID int = NULL OUTPUT,
	@EntityID int,
	@EntityAttributeTypeID int,
	@Value nvarchar(250)
)
AS
	SET NOCOUNT ON

	INSERT INTO [EntityAttribute]
	(
		[EntityID],
		[EntityAttributeTypeID],
		[Value]
	)
	VALUES
	(
		@EntityID,
		@EntityAttributeTypeID,
		@Value
	)

	SELECT @ID = SCOPE_IDENTITY();

	RETURN @@Error
GO
*/
--|--------------------------------------------------------------------------------
--| [UpdateEntityAttribute] - Update Procedure Script for EntityAttribute
--|--------------------------------------------------------------------------------
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id (N'[dbo].[UpdateEntityAttribute]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1) 
	DROP PROCEDURE [dbo].[UpdateEntityAttribute]
GO

/*CREATE PROCEDURE [dbo].[UpdateEntityAttribute]
(
	@ID int,
	@EntityID int,
	@EntityAttributeTypeID int,
	@Value nvarchar(250)
)
AS
	SET NOCOUNT ON
	
	UPDATE [EntityAttribute]
	SET
		[EntityID] = @EntityID,
		[EntityAttributeTypeID] = @EntityAttributeTypeID,
		[Value] = @Value
	WHERE 
		[ID] = @ID

	RETURN @@Error
GO
*/
--|--------------------------------------------------------------------------------
--| [DeleteEntityAttribute] - Update Procedure Script for EntityAttribute
--|--------------------------------------------------------------------------------
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id (N'[dbo].[DeleteEntityAttribute]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1) 
	DROP PROCEDURE [dbo].[DeleteEntityAttribute]
GO

/*CREATE PROCEDURE [dbo].[DeleteEntityAttribute]
(
	@ID int
)
AS
	SET NOCOUNT ON

	DELETE 
	FROM   [EntityAttribute]
	WHERE  
		[ID] = @ID

	RETURN @@Error
GO
*/
